package Operation;

import bookk.Book;
import bookk.BookList;

import java.util.Scanner;

public class BorrowOperation implements IOperation{
    /**
     * @param booklist
     */

    @Override
    public void work(BookList booklist) {
        Scanner sc =new Scanner(System.in);
        System.out.println("请输入要借阅的书籍");
        String name = sc.nextLine();
        int size = booklist.getUsesize();
        int i=  0;
        for ( i = 0; i < size; i++) {
            Book book = booklist.getBooks(i);
            if(book.getName().equals(name)){
                book.setBorrowed(true);
                System.out.println("借阅成功");
                System.out.println(book);
                return;
            }
        }
        System.out.println("你要借阅的书不存在");
    }
}
